﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
namespace project_soft.BLStub
{
  public  class Manger1 :Employee1
    {
        private DBStubLayer.MangerDAC1 mang;
        public Manger1()
        {
            mang = new DBStubLayer.MangerDAC1();
        }
        public bool Insert_Worker(Worker1 wo)
        {
            if (wo == null || !Vlidate_User_Name(Worker1.User_Name1) || wo.User_Address1 == null || wo.User_Password1 == null || wo.User_Phone1 <= 0 || wo.User_Salary1 <= 0 || wo.User_Ssn1 <= 0 || wo.User_Type1 <= 1 || wo.User_Address1 == "" || wo.User_Password1 == "" || Worker1.User_Name1 == null || Worker1.User_Name1 == "")
            {
                return false;
            }
            else
            {
                return mang.Insert_Worker(wo);
            }
        }
        public bool Vlidate_User_Name(string User_Name)
        {
            if (User_Name == null || User_Name.Equals("")) return false;
            else return mang.Vlidate_User_Name(User_Name);
        }
        public bool Delet_Worker(string User_Name)
        {
            if (User_Name == null || User_Name.Equals("")) return false;
            else return mang.Delet_Worker(User_Name);
        }

        public bool Check_Name_Manager(string User_Name)
        {

            if (User_Name == null || User_Name == "") return false;
            return !mang.Check_Name_Manager(User_Name);
        }
        public bool Delet_Product(BLStub.Product1 product)
        {
            if (product == null || !product.Check_Product_Name(product.Product_Name1) || product.Product_Name1 == "" || product.Product_Name1 == null)
                return false;
            if (product.Sales_Price1 <= 0 && product.Sales_Price1 <= product.Oraginal_Price1)
                return false;
            if (product.Oraginal_Price1 <= 0)
                return false;
            if ( product.Avalible_Quantity1 <= 0)
                return false;
            if (product.Critcal_Quantity1 <= 0)
                return false;
            return mang.Delet_Product(product);
        }
        public bool Update_Product(BLStub.Product1 product)
        {
            BLStub.Product1 pro = new BLStub.Product1();
            if (product == null || !product.Check_Product_Name(product.Product_Name1) || product.Product_Name1 == "" || product.Product_Name1 == null)
                return false;
            if (product.Sales_Price1 <= 0 && product.Sales_Price1 <= product.Oraginal_Price1)
                return false;
            if (product.Oraginal_Price1 < 0)
                return false;
            if (product.Avalible_Quantity1 < product.Critcal_Quantity1 || product.Avalible_Quantity1 <= 0)
                return false;
            if (product.Critcal_Quantity1 <= 0)
                return false;

            return mang.Update_Product(product);


        }
        public bool ShowTranscript(string fromDate, string toDate,ref  DataTable dt)
        {

            if (fromDate == null || toDate == null || fromDate =="//" || toDate=="//" || fromDate==""|| toDate=="")
                return false;
            else
                return mang.ShowTranscript(fromDate, toDate,ref dt);


        }
    }
}
